﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ThangNM.Admin.Default" MasterPageFile="~/PublicInterface/Admin.Master" %>
<%@ Register src="~/UserControl/MsgUC.ascx" tagname="MsgUC" tagprefix="uc3" %>

<asp:Content ID="cHead" runat="server" ContentPlaceHolderID="cphHead">
<script type="text/javascript" src="http://nguyenmanhthang.net/Scripts/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="http://nguyenmanhthang.net/Scripts/jsapi.JS"></script>
<script type="text/javascript">
    google.load("visualization", "1", { packages: ["corechart"] });
    google.setOnLoadCallback(drawChart());

    function drawChart() {
//        if (isCall != 1) {
//            return false;
//        }
        var optionsCategory = {
            title: 'Thống kê bảng Category'
        };
        $.ajax({
            type: "POST",
            url: "../Admin/WS_AJAX.aspx/GetChartData",
            data: "{'iType':0}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (r) {
                var dataCategory = google.visualization.arrayToDataTable(r.d);
                var chartCategory = new google.visualization.PieChart($("#chartCategory")[0]);
                chartCategory.draw(dataCategory, optionsCategory);
            },
            failure: function (r) {
                //alert(r.d);
            },
            error: function (r) {
                //alert('0 - ' + r.d);
            }
        });
        //======================================================================================================

        var optionsMedia = {
            title: 'Thống kê bảng Media'
        };
        $.ajax({
            type: "POST",
            url: "../Admin/WS_AJAX.aspx/GetChartData",
            data: "{'iType':1}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (r) {
                var dataMedia = google.visualization.arrayToDataTable(r.d);
                var chartMedia = new google.visualization.PieChart($("#chartMedia")[0]);
                chartMedia.draw(dataMedia, optionsMedia);
            },
            failure: function (r) {
                //alert(r.d);
            },
            error: function (r) {
                //alert('1 - ' + r.d);
            }
        });
        //======================================================================================================

        var optionsAccount = {
            title: 'Thống kê bảng Account'
        };
        $.ajax({
            type: "POST",
            url: "../Admin/WS_AJAX.aspx/GetChartData",
            data: "{'iType':2}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (r) {
                var dataAccount = google.visualization.arrayToDataTable(r.d);
                var chartAccount = new google.visualization.PieChart($("#chartAccount")[0]);
                chartAccount.draw(dataAccount, optionsAccount);
            },
            failure: function (r) {
                //alert(r.d);
            },
            error: function (r) {
                //alert('2 - ' + r.d);
            }
        });
        //======================================================================================================

        var optionsFile = {
            title: 'Thống kê bảng File'
        };
        $.ajax({
            type: "POST",
            url: "../Admin/WS_AJAX.aspx/GetChartData",
            data: "{'iType':3}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (r) {
                var dataFile = google.visualization.arrayToDataTable(r.d);
                var chartFile = new google.visualization.PieChart($("#chartFile")[0]);
                chartFile.draw(dataFile, optionsFile);
            },
            failure: function (r) {
                //alert(r.d);
            },
            error: function (r) {
                //alert('3 - ' + r.d);
            }
        });
        //======================================================================================================

        var optionsMonthYear = {
            title: 'Thống kê số lượng bài đăng theo tháng - năm'
        };
        $.ajax({
            type: "POST",
            url: "../Admin/WS_AJAX.aspx/GetChartData",
            data: "{'iType':4}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (r) {
                var dataMonthYear = google.visualization.arrayToDataTable(r.d);
                var chartMonthYear = new google.visualization.ColumnChart($("#chartMonthYear")[0]);
                chartMonthYear.draw(dataMonthYear, optionsMonthYear);
            },
            failure: function (r) {
                //alert(r.d);
            },
            error: function (r) {
                //alert('4 - ' + r.d);
            }
        });
        //======================================================================================================

        var optionsQuestionAnswer = {
            title: 'Thống kê bảng QuestionAnswer'
        };
        $.ajax({
            type: "POST",
            url: "../Admin/WS_AJAX.aspx/GetChartData",
            data: "{'iType':5}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (r) {
                var dataQuestionAnswer = google.visualization.arrayToDataTable(r.d);
                var chartQuestionAnswer = new google.visualization.PieChart($("#chartQuestionAnswer")[0]);
                chartQuestionAnswer.draw(dataQuestionAnswer, optionsQuestionAnswer);
            },
            failure: function (r) {
                //alert(r.d);
            },
            error: function (r) {
                //alert('5 - ' + r.d);
            }
        });
        //======================================================================================================

        var optionsTopic = {
            title: 'Thống kê bảng Topic'
        };
        $.ajax({
            type: "POST",
            url: "../Admin/WS_AJAX.aspx/GetChartData",
            data: "{'iType':6}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (r) {
                var dataTopic = google.visualization.arrayToDataTable(r.d);
                var chartTopic = new google.visualization.PieChart($("#chartTopic")[0]);
                chartTopic.draw(dataTopic, optionsTopic);
            },
            failure: function (r) {
                //alert(r.d);
            },
            error: function (r) {
                //alert('6 - ' + r.d);
            }
        });
        //======================================================================================================

        var optionsMonthYearMedia = {
            title: 'Thống kê số lượng bài đăng theo tháng - năm'
        };
        $.ajax({
            type: "POST",
            url: "../Admin/WS_AJAX.aspx/GetChartData",
            data: "{'iType':7}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (r) {
                var dataMonthYearMedia = google.visualization.arrayToDataTable(r.d);
                var chartMonthYearMedia = new google.visualization.ColumnChart($("#chartMonthYearMedia")[0]);
                chartMonthYearMedia.draw(dataMonthYearMedia, optionsMonthYearMedia);
            },
            failure: function (r) {
                //alert(r.d);
            },
            error: function (r) {
                //alert('7 - ' + r.d);
            }
        });
        //======================================================================================================

        var optionsDatabase = {
            title: 'Database'
        };
        $.ajax({
            type: "POST",
            url: "../Admin/WS_AJAX.aspx/GetChartData",
            data: "{'iType':8}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (r) {
                var dataDatabase = google.visualization.arrayToDataTable(r.d);
                var chartDatabase = new google.visualization.ColumnChart($("#chartDatabase")[0]);
                chartDatabase.draw(dataDatabase, optionsDatabase);
            },
            failure: function (r) {
                //alert(r.d);
            },
            error: function (r) {
                //alert('8 - ' + r.d);
            }
        });
        //======================================================================================================

//        var optionsDataFile = {
//            title: 'Data file size, Max/Used/Usage (MB)'
//        };
//        $.ajax({
//            type: "POST",
//            url: "../Admin/WS_AJAX.aspx/GetChartData",
//            data: "{'iType':9}",
//            contentType: "application/json; charset=utf-8",
//            dataType: "json",
//            success: function (r) {
//                var dataDataFile = google.visualization.arrayToDataTable(r.d);
//                var chartDataFile = new google.visualization.PieChart($("#chartDataFile")[0]);
//                chartDataFile.draw(dataDataFile, optionsDataFile);
//            },
//            failure: function (r) {
//                alert(r.d);
//            },
//            error: function (r) {
//                alert('9 - ' + r.d);
//            }
//        });
//        //======================================================================================================


//        var optionsLogFile = {
//            title: 'Log file size, Max/Used/Usage (MB)'
//        };
//        $.ajax({
//            type: "POST",
//            url: "../Admin/WS_AJAX.aspx/GetChartData",
//            data: "{'iType':10}",
//            contentType: "application/json; charset=utf-8",
//            dataType: "json",
//            success: function (r) {
//                var dataLogFile = google.visualization.arrayToDataTable(r.d);
//                var chartLogFile = new google.visualization.PieChart($("#chartLogFile")[0]);
//                chartLogFile.draw(dataLogFile, optionsLogFile);
//            },
//            failure: function (r) {
//                alert(r.d);
//            },
//            error: function (r) {
//                alert('10 - ' + r.d);
//            }
//        });
//        //======================================================================================================
    }
</script>
</asp:Content>
<asp:Content ID="cBody" runat="server" ContentPlaceHolderID="cphBody">
    <uc3:MsgUC ID="MsgUC1" runat="server" />
    <asp:Panel ID="pnlMain" runat="server">
        <div class="bs-example">
            <ul class="nav nav-tabs">
                <li><a href="#tabTopic" data-toggle="tab" data-toggle="tab" onclick="drawChart(1);">Bài viết</a></li>
                <li><a href="#tabMedia" data-toggle="tab" data-toggle="tab" onclick="drawChart(1);">Giải trí</a></li>
                <li class="active"><a data-toggle="tab" href="#tabCategory" data-toggle="tab" onclick="drawChart(1);">Danh mục</a></li>
                <li><a href="#tabAccount" data-toggle="tab" onclick="drawChart(1);">Tài khoản</a></li>
                <li><a href="#tabFile" data-toggle="tab" onclick="drawChart(1);">File chia sẻ</a></li>
                <li><a href="#tabQuestionAnswer" data-toggle="tab" onclick="drawChart(1);">Hỏi đáp</a></li>
                <li><a href="#tabDatabase" data-toggle="tab" onclick="drawChart(1);">Database</a></li>
            </ul>
            <div class="tab-content">
                <div id="tabTopic" class="tab-pane fade">
                    <br /><br />
                    <div id="chartTopic" style="width: 500px; height: 200px;"></div><br />
                </div>
                <div id="tabMedia" class="tab-pane fade">
                    <br /><br />
                    <div id="chartMonthYearMedia" style="width: 100%; height: 100%;"></div><br /><br />
                    <div id="chartMedia" style="width: 500px; height: 200px;"></div><br />
                </div>
                <div id="tabCategory" class="tab-pane fade in active">
                    <br /><br />
                    <div id="chartMonthYear" style="width: 100%; height: 100%;"></div><br /><br />
                    <div id="chartCategory" style="width: 800px; height: 600px;"></div><br />
                </div>
                <div id="tabAccount" class="tab-pane fade">
                    <br /><br />
                    <div id="chartAccount" style="width: 500px; height: 200px;"></div><br />
                </div>
                <div id="tabFile" class="tab-pane fade">
                    <br /><br />
                    <div id="chartFile" style="width: 500px; height: 200px;"></div><br />
                </div>
                <div id="tabQuestionAnswer" class="tab-pane fade">
                    <br /><br />
                    <div id="chartQuestionAnswer" style="width: 500px; height: 200px;"></div><br />
                </div>
                <div id="tabDatabase" class="tab-pane fade">
                    <br /><br />
                    <div id="chartDatabase" style="width: 100%; height: 100%;"></div><br /><br />
                    <div id="chartDataFile" style="width: 500px; height: 200px;"></div><br />
                    <div id="chartLogFile" style="width: 500px; height: 200px;"></div><br />
                </div>
            </div>
        </div>
    </asp:Panel>
    <br /><br /><br /><br /><br />
</asp:Content>
